<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" >
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/echarts/echarts.min.js}" charset="utf-8"></script>
</head>
<body>
<div id="container" style="height: 550px;width:600px%"></div>

<script type="text/javascript">
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};
    option = null;
    layui.use("layer",function () {
        var $ = layui.jquery;

        $.get("/dataanalysis/monthincomes",function (resp) {
            var dates =new Array();
            var incomes =new Array();
            for(var i=0;i<resp.length;i++){
                var item = resp[i];
                dates[i] = item.date;
                incomes[i] = item.income;
            }
            option = {
                xAxis: {type: 'category',data: dates },
                yAxis: {type: 'value'},
                series: [{
                    data: incomes,
                    barWidth:20,
                    type: 'bar'
                }]
            };
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        });
    });
</script>
</body>
</html>
